<?php
/**
 * RemoveShift Function
 *
 * Remove an existing shift.
 *
 * @author Max Sibbald <maxsibbald@gmail.com>
 */
include_once 'UTerrorcode.php';
include_once 'UTcheckAuth.php';
include_once 'UTDBGlobal.php';

/**
 * @param $authUser string
 * @param $authUserPass string
 * @param $roleID string
 * @param $dateID string
 * @param $empID string
 * @return array
 */
function removeShift($authUser, $authUserPass, $roleID, $dateID, $empID)
{
	global $dbaddress;
    global $dbuser;
    global $dbpassword;
    global $dbdatabasename;
	
      if (checkAuthorization($authUser, $authUserPass) != true){
	     return array(ErrorCode::authFailRead);	
      }

      $conn=mysql_connect($dbaddress,$dbuser,$dbpassword,$dbdatabasename);
      if(!$conn)
      {
           die('Could not connect: ' . mysql_error());
         return array(ErrorCode::sysError);
      }
      $sql = "DELETE FROM roleDate WHERE roleID='$roleID' AND dateID='$dateID' AND empID='$empID'";
      if (mysql_query($conn, $sql)){
        mysql_close($conn);
       return array(ErrorCode::SuccessDelete);
      } else {
            mysql_close($conn);
            return array(ErrorCode::failDelete);
      }
}

?>